﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Lucky_bgy
{
    public static class ConfigHelper
    {
        
        public static Dictionary<string, string> configs = new Dictionary<string,string>();

        public static void refParam(){
            DBHelper helper = new DBHelper();

            DataTable dt = helper.ExecuteDataTable("select * from sys_config where valid_flag=1", null);

            configs = new Dictionary<string, string>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                configs.Add(dt.Rows[i]["config_name"].ToString(), dt.Rows[i]["config_value"].ToString());
            }
        }

        public static string get(string code)
        {
            
            refParam();

            if (configs.Keys.Count == 0)
            {
                return "";
            }
            else
            {
                if (configs.ContainsKey(code))
                {
                    return configs[code];
                }
                else
                {
                    return "";
                }
            }
        }


    }
}
